package com.calvin.study.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.calvin.study.service.IProductService;

import cloud.alibaba.study.entity.base.ResponseVo;
import cloud.alibaba.study.entity.product.Product;

@Controller
@RequestMapping("product")
public class ProductController {

	@Autowired
	private IProductService productService;

	/**
	 * @Title: getDetail   
	 * @Description: 商品信息查询
	 * @date: 2022年8月9日 上午8:44:26   
	 * @version:
	 * @param productId
	 * @return          
	 * @throws
	 */
	@RequestMapping("getDetail/{productId}")
	public @ResponseBody ResponseVo getDetail(@PathVariable("productId") Long productId) {
		try {
			Product product = productService.getProductDetail(productId);
			return ResponseVo.success(product);
		} catch (Exception e) {
			return ResponseVo.failure(e.getMessage());
		}
	}

}
